import ReactDOMServer from 'react-dom/server'
import { StaticRouter } from 'react-router-dom'
import { App } from './App'
import { GlobalContext } from './globalContext'

const renderContext = (context) => {
  return <GlobalContext.Provider value={ context}>
        <App />
     </GlobalContext.Provider>
}

export function render(url: string, context: any) {
 
  return ReactDOMServer.renderToString(
    <StaticRouter location={url} context={context}>
      { renderContext(context)}
    </StaticRouter>
  )
}
